#include <iostream>
using namespace std;

class Person 
{

    public:
       Person(){
         cout<< "Person()"<<endl;
       }
      virtual ~Person(){
         cout<< "~Person()"<<endl;
       }
      virtual void work(){
           cout <<"Person()::work()"<<endl;
       }
       
};

class Student: virtual public Person
{

    public:
       Student(){
        cout<< "Student()"<<endl;
       }
       virtual ~Student(){
        cout << "~Student()"<<endl;
       }
       virtual void work(){
           cout <<"Student()::work()"<<endl;
       }
       
    
};
class Teacher: public Person
{

    public:
       Teacher(){
        cout << "Teacher()"<<endl;
       }
       virtual ~Teacher(){
        cout << "~Teacher()"<<endl;
       }
       virtual void work(){
           cout <<"Teacher()::work()"<<endl;
       }
  

};


int main(){
  
    Person *per = new Person;
    Person *stu = new Student;
    Person *tea = new Teacher;
    per->work();
    stu->work();
    tea->work();
    delete per;
    per = nullptr;
    delete stu;
    stu = nullptr;
    delete tea;
    tea = nullptr;
    return 0;
    return 0;
    
}